package com.slz3.business.module.socialManagement.socArticle.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.socialManagement.socArticle.domain.SocArticle;
import com.slz3.business.module.socialManagement.socArticle.domain.SocArticleCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class SocArticleResController {

    @Resource
    private SocArticleResAtomic socArticleResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, SocArticle socArticle) {
        if (SocArticleResUnsafeValid.add(req, socArticle)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.add_$SocArticleUpdateLock(req, socArticle);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, SocArticleCondition socArticleCondition) {
        if (SocArticleResUnsafeValid.delete(req, socArticleCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.delete_$SocArticleUpdateLock(req, socArticleCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, SocArticle socArticle) {
        if (SocArticleResUnsafeValid.modify(req, socArticle)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.modify_$SocArticleUpdateLock(req, socArticle);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (SocArticleResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return SocArticleResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return socArticleResAtomic.info_$SocArticleUpdateLock(req);
        if (SocArticleResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.info_$SocArticleUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (SocArticleResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return SocArticleResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, SocArticleCondition socArticleCondition) {
        //
        if (SocArticleResUnsafeValid.auditSubmit(req, socArticleCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.auditSubmit_$SocArticleUpdateLock(req, socArticleCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, SocArticleCondition socArticleCondition) {
        if (SocArticleResUnsafeValid.audit(req, socArticleCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.audit_$SocArticleUpdateLock(req, socArticleCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, SocArticleCondition socArticleCondition) {
        if (SocArticleResUnsafeValid.auditReject(req, socArticleCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.auditReject_$SocArticleUpdateLock(req, socArticleCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, SocArticleCondition socArticleCondition) {
        if (SocArticleResUnsafeValid.usingEnable(req, socArticleCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.usingEnable_$SocArticleUpdateLock(req, socArticleCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, SocArticleCondition socArticleCondition) {
        if (SocArticleResUnsafeValid.usingDisable(req, socArticleCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return socArticleResAtomic.usingDisable_$SocArticleUpdateLock(req, socArticleCondition);
        }
    }

}
